import 'package:flutter/material.dart';
import 'package:flutter_ahj_app/app/my/invoicing/viewModel/invoicingViewModel.dart';
import 'package:flutter_ahj_app/base/basewidget/view/BaseWidget.dart';
import 'package:flutter_ahj_app/base/utils/JUIKit/JText.dart';
import 'package:flutter_ahj_app/base/utils/mTopBar.dart';
import 'package:flutter_ahj_app/base/values/SQColor.dart';



class InvoicingView extends BaseStatefulWidget {
  @override
  State<StatefulWidget> initState() {
    // TODO: implement initState
    return _InvoicingViewSate();
  }
}

class _InvoicingViewSate extends BaseState<InvoicingViewModel, InvoicingView> {
  ///cell标题数组
  List _titleList = [];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    _titleList = [
      "待开票列表",
      "开票历史",
      "开票设置",
      "发票地址",
    ];
  }

  @override
  Widget initWidget() {
    // TODO: implement initWidget
    return Scaffold(
      backgroundColor: SQColor.lightGray,
      appBar: MTopBar(title: '发票管理').create(),
      body: _bodyView(),
    );
  }

  /// bodyView
  Widget _bodyView() {
    return SafeArea(
      child: Container(
        color: Colors.white,
        child: ListView.builder(
          itemCount: _titleList.length,
          shrinkWrap: true,
          itemBuilder: (BuildContext context, int index) {
            return Column(
              children: <Widget>[
                ListTile(
                  onTap: () => _onTapEvent(_titleList[index]),
                  title: JText(_titleList[index]),
                  trailing: Row(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      index == 1
                          ? JText(
                              '申请作废',
                              color: SQColor.textColorListSubTitle,
                            )
                          : Container(),
                      Icon(Icons.arrow_forward_ios),
                    ],
                  ),
                ),
                Divider(
                  height: 1,
                )
              ],
            );
          },
        ),
      ),
    );
  }

  ///cell event
  _onTapEvent(String title) {
    switch (title) {
      case '待开票列表':
        Navigator.pushNamed(context, "/OrderInvoicingView");
        break;
      case '开票历史': 
      Navigator.pushNamed(context, "/InvovingHistoryView");
        break;
      case '开票设置': 
      Navigator.pushNamed(context, "/IncoicSettingListView");
        break;
      case '发票地址':
      Navigator.pushNamed(context, "/InvoicAdressListView");
        break;
      default:
    }
  }
}
